package com.heima.jopo.servlet;

import com.heima.jopo.obj.UserInfo;
import com.heima.jopo.web.UpdateInfo;
import com.heima.jopo.web.Updatexg;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.EOFException;
import java.io.IOException;

@WebServlet(name = "niubi",urlPatterns ="/update")
public class UpdateServlet  extends HttpServlet{

    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            //获取到要修改的ID
        String uid = request.getParameter("uid");


        UpdateInfo updateInfo=new UpdateInfo();

        if (updateInfo==null){
            response.sendRedirect("errer.jsp");
        }
        //查出来修改ID的数据
        UserInfo userInfo = updateInfo.selectInfo(Integer.valueOf(uid));

        HttpSession session = request.getSession();



        session.setAttribute("usinfo",userInfo);
        session.setAttribute("uid1",uid);
        request.getRequestDispatcher("update.jsp").forward(request,response);
    }
}
